********************************************************************************
*  		      CLEANING THE ENDLINE TEACHER MONITORING SURVEY	               *
*===============================================================================
* Date created: 18th/02/2019												   *
* Version : Stata 15                            							   *
* Description: This dofile is part of the cleaning activity of the endline     *
*             teacher monitoring survey. This particular do-file iterates/     *
* describes all steps undertaken to clen this dataset                          *
********************************************************************************


*************TEACHER MONITORING SURVEY CLEANINGS************
clear
set more off
cd "[directory]/Raw"
use "Endline Teacher Monitoring Final.dta"


*SECTION 1. I. School and Teacher Identification
*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*

*Dropping varibales having no information
drop subscriberid simid devicephonenum enumname_other teacherdoing_200_o

*300
**adding labels to question: observations_300 :During the observed class period, did you observe any of the following activitie

lab def yesnolbl 1 Yes 0 No
foreach var in observations_300_1 observations_300_2 observations_300_3 observations_300_4 observations_300_5 observations_300_6 observations_300_7 observations_300_8 observations_300_9 observations_300__66{
lab var `var' "During the observed class period, did you observe any of the following activities"
lab val `var' yesnolbl 

}

**adding notes notes observations_300: During the observed class period, did you observe any of the following activities?
notes observations_300_1: During the observed class period, did you observe any of the following activities?
notes observations_300_2: During the observed class period, did you observe any of the following activities?
notes observations_300_3: During the observed class period, did you observe any of the following activities?
notes observations_300_4: During the observed class period, did you observe any of the following activities?
notes observations_300_5: During the observed class period, did you observe any of the following activities?
notes observations_300_6: During the observed class period, did you observe any of the following activities?
notes observations_300_7: During the observed class period, did you observe any of the following activities?
notes observations_300_8: During the observed class period, did you observe any of the following activities?
notes observations_300_9: During the observed class period, did you observe any of the following activities?
notes observations_300__66: During the observed class period, did you observe any of the following activities?


*304
**adding labels to learning_aid_304 : "304. What learning aids did teachers use or refer to during the class"
destring learning_aid_304_other, replace
foreach var in learning_aid_304_1 learning_aid_304_2 learning_aid_304_3 learning_aid_304_4 learning_aid_304_5 learning_aid_304_other{
lab var `var' "304. What learning aids did teachers use or refer to during the class"
lab val `var' yesnolbl 

}

**Adding notes to learning_aid_304: "304. What learning aids did teachers use or refer to during the class"

notes learning_aid_304_1: "304. What learning aids did teachers use or refer to during the class"
notes learning_aid_304_2: "304. What learning aids did teachers use or refer to during the class"
notes learning_aid_304_3: "304. What learning aids did teachers use or refer to during the class"
notes learning_aid_304_4: "304. What learning aids did teachers use or refer to during the class"
notes learning_aid_304_5: "304. What learning aids did teachers use or refer to during the class"


rename v354 learning_aid_304_specify_other
drop v433 v467
rename v454 researchtopics_321_specify_other
rename v489 financetopics_325_specify_other
rename v502 grouptopics_326_specify_other
rename v512 researchtopics_327_specify_other
rename v523 casestudytopics_328_specif_other
rename v529 roleplaytopics_329_specify_other
rename v539 financetopics_330_specify_other


*308
*adding labels to 

foreach var in yes_present_308_1 yes_present_308_2 yes_present_308_3 yes_present_308_4 yes_present_308_5{
lab var `var' "308: If students presented, did"
lab val `var' yesnolbl 

}

*adding notes to yes_present_308: 308: If students presented, did
notes yes_present_308_1: 308: If students presented, did
notes yes_present_308_2: 308: If students presented, did
notes yes_present_308_3: 308: If students presented, did
notes yes_present_308_4: 308: If students presented, did
notes yes_present_308_5: 308: If students presented, did


*310
**adding labels to groupdiscussion_309: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
foreach var in grouptopics_310_1 grouptopics_310_2 grouptopics_310_3 grouptopics_310_4 grouptopics_310_5 grouptopics_310_6 grouptopics_310_7 grouptopics_310_8 grouptopics_310_9 grouptopics_310_10 grouptopics_310_11 grouptopics_310__66{
lab var `var' "310. Did the Group Discussion cover any of the following topics (check all that apply)"
lab val `var' yesnolbl 

}

**Adding notes to grouptopics_310 "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_1: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_2: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_3: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_4: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_5: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_6: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_7: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_8: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_9: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_10: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310_11: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_310__66: "310. Did the Groupe Discussion cover any of the following topics (check all that apply)"


*312
**adding labels to
foreach var in researchtopics_312_1 researchtopics_312_2 researchtopics_312_3 researchtopics_312_4 researchtopics_312_5 researchtopics_312_6 researchtopics_312__66{
lab var `var' "312. Did the Research cover any of the following topics? (check all that apply)"
lab val `var' yesnolbl 

}

**adding notes to
notes researchtopics_312_1: "312. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_312_2: "312. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_312_3: "312. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_312_4: "312. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_312_5: "312. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_312_6: "312. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_312__66: "312. Did the Research cover any of the following topics? (check all that apply)"


*314
**adding labels to
foreach var in casestudytopics_314_1 casestudytopics_314_2 casestudytopics_314_3 casestudytopics_314_4 casestudytopics_314__66{
lab var `var' "314. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
lab val `var' yesnolbl 

}


**adding notes to  
notes casestudytopics_314_1: "314. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_314_2: "314. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_314_3: "314. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_314_4: "314. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_314__66: "314. Did the Case Study Discussion cover any of the following topics? (check all that apply)"


*316
**Adding labels to
foreach var in roleplaytopics_316_1 roleplaytopics_316_2 roleplaytopics_316_3 roleplaytopics_316_4 roleplaytopics_316_5 roleplaytopics_316_6 roleplaytopics_316__66{
lab var `var' "316. Did the Role Play cover any of the following topics? (check all that apply))"
lab val `var' yesnolbl 

}


**adding notes to
notes roleplaytopics_316_1: "316. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_316_2: "316. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_316_3: "316. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_316_4: "316. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_316_5: "316. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_316_6: "316. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_316__66: "316. Did the Role Play cover any of the following topics? (check all that apply)"


*318
**adding labels to
destring financetopics_319_other, replace
foreach var in financetopics_318_1 financetopics_318_2 financetopics_318_3 financetopics_318_4 financetopics_318_5 financetopics_318_6 financetopics_318__66{
lab var `var' "318. Did the Finance Practice cover any of the following topics? (check all that"
lab val `var' yesnolbl 

}

**adding notes to 
notes financetopics_318_1: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_318_2: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_318_3: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_318_4: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_318_5: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_318_6: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_318__66: "318. Did the Finance Practice cover any of the following topics? (check all that apply)"


*320
**adding labels
destring grouptopics_320_other, replace
foreach var in grouptopics_320_1 grouptopics_320_2 grouptopics_320_3 grouptopics_320_4 grouptopics_320_5 grouptopics_320_6 grouptopics_320_7 grouptopics_320_8 grouptopics_320_9 grouptopics_320_10 grouptopics_320_11 grouptopics_320__66 grouptopics_320_other{
lab var `var' "320. Did the Groupe Discussion cover any of the following topics (check all that"
lab val `var' yesnolbl 

}

**adding notes
notes grouptopics_320_1: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_2: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_3: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_4: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_5: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_6: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_7: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_8: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_9: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_10: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320_11: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_320__66: "320. Did the Groupe Discussion cover any of the following topics (check all that apply)"


*321
**adding labels to 
destring researchtopics_321_other, replace
foreach var in researchtopics_321_1 researchtopics_321_2 researchtopics_321_3 researchtopics_321_4 researchtopics_321_5 researchtopics_321_6 researchtopics_321_7 researchtopics_321_8 researchtopics_321_9 researchtopics_321_10 researchtopics_321_11 researchtopics_321_12 researchtopics_321_13 researchtopics_321_14 researchtopics_321_15 researchtopics_321_16 researchtopics_321__66 researchtopics_321_other{
lab var `var' "320. Did the Groupe Discussion cover any of the following topics (check all that"
lab val `var' yesnolbl 

}

**Adding notes to
notes researchtopics_321_1: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_2: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_3: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_4: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_5: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_6: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_7: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_8: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_9: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_10: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_11: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_12: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_13: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_14: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_15: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321_16: "321. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_321__66: "321. Did the Research cover any of the following topics? (check all that apply)"


*323
**adding labels to
destring casestudytopics_323_other, replace
foreach var in casestudytopics_323_1 casestudytopics_323_2 casestudytopics_323_3 casestudytopics_323_4 casestudytopics_323_5 casestudytopics_323_6 casestudytopics_323_7 casestudytopics_323_8 casestudytopics_323__66 casestudytopics_323_other{
lab var `var' "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
lab val `var' yesnolbl 

}

**adding notes to
notes casestudytopics_323_1: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_2: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_3: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_4: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_5: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_6: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_7: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323_8: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_323__66: "323. Did the Case Study Discussion cover any of the following topics? (check all that apply)"


*324
**adding labels to 
destring roleplaytopics_324_other, replace
foreach var in roleplaytopics_324_4 roleplaytopics_324_5 roleplaytopics_324_6 roleplaytopics_324_7 roleplaytopics_324_8 roleplaytopics_324_9 roleplaytopics_324__66 roleplaytopics_324_other{
lab var `var' "324. Did the Role Play cover any of the following topics? (check all that apply)"
lab val `var' yesnolbl 

}

**adding notes to
notes roleplaytopics_324_4: "324. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_324_5: "324. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_324_6: "324. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_324_7: "324. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_324_8: "324. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_324_9: "324. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_324__66: "324. Did the Role Play cover any of the following topics? (check all that apply)"


*325
**adding labels to
destring financetopics_325_other, replace
foreach var in financetopics_325_1 financetopics_325_2 financetopics_325_3 financetopics_325_4 financetopics_325_5 financetopics_325_6 financetopics_325__66 financetopics_325_other{
lab var `var' "325. Did the Finance Practice cover any of the following topics? (check all that appply)"
lab val `var' yesnolbl 

}

**adding notes to
notes financetopics_325_1: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_325_2: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_325_3: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_325_4: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_325_5: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_325_6: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_325__66: "325. Did the Finance Practice cover any of the following topics? (check all that apply)"


*326
**adding labels to 
destring grouptopics_326_other, replace
foreach var in grouptopics_326_1 grouptopics_326_2 grouptopics_326_3 grouptopics_326_4 grouptopics_326_5 grouptopics_326_6 grouptopics_326_7 grouptopics_326_8 grouptopics_326_9 grouptopics_326_other{
lab var `var' "326. Did the Groupe Discussion cover any of the following topics (check all that"
lab val `var' yesnolbl 

}

**adding notes to 
notes grouptopics_326_1: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_2: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_3: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_4: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_5: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_6: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_7: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_8: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"
notes grouptopics_326_9: "326. Did the Groupe Discussion cover any of the following topics (check all that apply)"


*327
**adding labels to
destring researchtopics_327_other, replace

foreach var in researchtopics_327_1 researchtopics_327_2 researchtopics_327_3 researchtopics_327_4 researchtopics_327_5 researchtopics_327__66 researchtopics_327_other{
lab var `var' "327. Did the Research cover any of the following topics? (check all that apply)"
lab val `var' yesnolbl 

}

**adding notes to
notes researchtopics_327_1: "327. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_327_2: "327. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_327_3: "327. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_327_4: "327. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_327_5: "327. Did the Research cover any of the following topics? (check all that apply)"
notes researchtopics_327__66: "327. Did the Research cover any of the following topics? (check all that apply)"


*328
*adding labels to
destring casestudytopics_328_other, replace
foreach var in casestudytopics_328_1 casestudytopics_328_2 casestudytopics_328_3 casestudytopics_328_4 casestudytopics_328_5 casestudytopics_328_6 casestudytopics_328_7 casestudytopics_328_other{
lab var `var' "328. Did the Case Study Discussion cover any of the following topics? (check all"
lab val `var' yesnolbl 

}

**adding notes to 
notes casestudytopics_328_1: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_328_2: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_328_3: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_328_4: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_328_5: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_328_6: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"
notes casestudytopics_328_7: "328. Did the Case Study Discussion cover any of the following topics? (check all that apply)"


*329
**adding labels to 
destring roleplaytopics_329_other, replace
foreach var in roleplaytopics_329_4 roleplaytopics_329_5 roleplaytopics_329_other{
lab var `var' "329. Did the Role Play cover any of the following topics? (check all that apply)"
lab val `var' yesnolbl 

}

**adding notes to 
notes roleplaytopics_329_4: "329. Did the Role Play cover any of the following topics? (check all that apply)"
notes roleplaytopics_329_5: "329. Did the Role Play cover any of the following topics? (check all that apply)"

*330
**adding labels
destring financetopics_330_other, replace
foreach var in financetopics_330_1 financetopics_330_2 financetopics_330_3 financetopics_330_4 financetopics_330_5 financetopics_330_6 financetopics_330_other{
lab var `var' "330. Did the Finance Practice cover any of the following topics? (check all that)"
lab val `var' yesnolbl 

}

**adding notes
notes financetopics_330_1: "330. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_330_2: "330. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_330_3: "330. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_330_4: "330. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_330_5: "330. Did the Finance Practice cover any of the following topics? (check all that apply)"
notes financetopics_330_6: "330. Did the Finance Practice cover any of the following topics? (check all that apply)"


**********************
replace teacherid = 4031042 if teacherid == 4031041 & key == "uuid:ed54b044-ccb7-4186-837a-d40c81cfb7da"
replace reenter_teacherid = 4031042 if reenter_teacherid == 4031041 & key == "uuid:ed54b044-ccb7-4186-837a-d40c81cfb7da"

replace teacherid = 4051242 if teacherid == 4051241 & key ==  "uuid:e928b3ed-0fb9-486d-b7ac-ae21bfc6fb80"
replace reenter_teacherid = 4051242 if reenter_teacherid == 4051241 & key == "uuid:e928b3ed-0fb9-486d-b7ac-ae21bfc6fb80"

**GS Juru Kayonza
replace schoolid = 504102 if schoolid == 5041021
replace reenter_schoolid = 504102 if reenter_schoolid == 5041021


**GS Muko II
replace schoolid = 504108 if schoolid == 5041081
replace reenter_schoolid = 504108 if reenter_schoolid == 5041081

**GS Zaza A
replace schoolid = 506118 if schoolid == 605118
replace reenter_schoolid = 506118 if reenter_schoolid == 605118

**GS Gasange
replace schoolid = 503104 if schoolid == 503204
replace reenter_schoolid = 503104 if reenter_schoolid == 503204

**GS Gihengeri
replace schoolid = 503107 if schoolid == 5033107
replace reenter_schoolid = 503107 if reenter_schoolid == 5033107

**GS Mubuga
replace schoolid = 402121 if schoolid == 4021211
replace reenter_schoolid = 402121 if reenter_schoolid == 4021211

**ES Ruganda
replace schoolid = 301015 if schoolid == 3010153
replace reenter_schoolid = 301015 if reenter_schoolid == 3010153

*********************************
tostring schoolid, replace
*drop if schoolid == "605118" & key == "uuid:45d59c0e-4017-433c-b65e-d9d033f4f376"
gen myidstr = "0" + schoolid
merge m:m myidstr using "t_addedbasinfo.dta"
drop if _merge == 2
drop _merge
rename myidstr schoolid_bas
*order province district sector cell village school schoolid_bas distrloc_106 publ_priv_108 board_day_109 group_110, after(reenter_schoolid)
order schoolid_bas, after(reenter_schoolid)

order bl_province_100 bl_district_101 bl_sector_102 bl_cell_103 bl_village_104 bl_distrloc_105 bl_school_name_106 bl_publ_priv_108 bl_group_111, after(schoolid_bas)

drop province_100 district_101 sector_102 cell_103 village_104

rename (bl_province_100 bl_district_101 bl_sector_102 bl_cell_103 bl_village_104)(province_100 district_101 sector_102 cell_103 village_104)
drop school_105 
rename (bl_distrloc_105 bl_school_name_106 bl_publ_priv_108 bl_group_111) (distrloc_105 school_name_106 ubl_priv_108 group_111)

order province_100 district_101 sector_102 cell_103 village_104 distrloc_105 school_name_106 ubl_priv_108 group_111, after(schoolid_bas)

la de group_111 1 "Treatment" 2 "Control", modify

	
replace teacherid = 4051061 if teacherid == 4051062 & key == "uuid:2ae95aa4-f830-4e3c-b507-26a6d7233af6"
replace reenter_teacherid = 4051061 if reenter_teacherid == 4051062  & key == "uuid:2ae95aa4-f830-4e3c-b507-26a6d7233af6"

//correcting reacherid
replace teacherid = 3011352 if teacherid == 3011351
replace teacherid = 3050371 if teacherid == 305037
replace teacherid = 4021113 if teacherid == 4021111
replace teacherid = 4020321 if teacherid == 402321
replace teacherid = 4030502 if teacherid == 4030501
replace teacherid = 4051022 if teacherid == 4050352
replace teacherid = 4051112 if teacherid == 405112
*replace teacherid = 4051241 if teacherid == 4051242
replace teacherid = 5030562 if teacherid == 5030561
replace teacherid = 5031182 if teacherid == 5031184
replace teacherid = 5040301 if teacherid == 5040303
replace teacherid = 5060322 if teacherid == 5060321
replace teacherid = 5071231 if teacherid == 50712331
replace teacherid = 5061181 if teacherid == 6051182

*gen uniqueid = reenter_teacherid
rename teacherid uniqueid
tostring uniqueid, replace
order uniqueid, before(deviceid)

***CLEANING DOFILE
rename group_111 schoolgroup_107
rename teacherdoing_200 teacherdoing_200 
rename enumename enumerator
rename schoolid schoolcode_106


save "04 Endline_Teacher_Monitoring_Final_Clean.dta", replace
